<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ page
	import="java.sql.Connection,java.sql.DriverManager,javax.naming.Context,javax.naming.InitialContext,javax.naming.NamingException,javax.sql.DataSource"%>
<%
	/*In this page, we open the connection to the Database
	 */
	Connection oConn = null;
	/*In this page, we open the connection to the Database
	 Our MySQL database.
	 It's a very simple database with just 2 tables (for the sake of demo).
	 Ideally the Connection to the database should be made in a Java class or using Connection Pooling component
	 Here the Data Source name comes from the web.xml.
	 */
	oConn = null;

	try {
		Class.forName("com.mysql.jdbc.Driver");
		oConn = DriverManager
				.getConnection("jdbc:mysql://localhost:3306/factorydb",
						"root", "root");
		/*
		Context initContext = new InitialContext();
		Context envContext  = (Context)initContext.lookup("java:/comp/env");
		DataSource ds = (DataSource)envContext.lookup("jdbc/FactoryDB");
		oConn = ds.getConnection();
		 */
	} catch (java.sql.SQLException e) {
		e.printStackTrace();
	}
%>